﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Repositories;
using Domain.Entities;
using Database.NHibernateInterface;
using NHibernate.Criterion;

namespace Database.Repositories
{
   public class ChapterRepository:BaseRepository<Chapter>, IChapterRepository
    {
       public ChapterRepository(ISessionProvider sessionProvider):base(sessionProvider)
       {
       }

       public IEnumerable<Chapter> GetByTopic(Topic topic)
       {
           return Session.CreateCriteria<Chapter>().Add(Restrictions.Eq("Topic", topic)).List<Chapter>();
       }
       public override IEnumerable<Chapter> GetAll()
       {
           return base.GetAll().OrderBy(x => x.NumberInOrder);
       }
    }
}
